//
//  DetailViewController.m
//  ipad.demo
//
//  Created by wangjun on 10-10-18.
//  Copyright 2010 __MyCompanyName__. All rights reserved.
//
#import "DetailViewController.h"
@implementation DetailViewController
@synthesize lable,switch1,toolbar,popoverController;
- (void)viewDidLoad {
    [super viewDidLoad];
}
-(void)viewWillAppear:(BOOL)animated
{

}
-(void)deetail:(id)sender
{
	index=sender;
	
	self.lable.text=[NSString stringWithFormat:@"Row %d,section %d",[index row],[index section]];
	if ([index row]%2==0) {
		self.switch1.on=YES;
	}else {
		self.switch1.on=NO;
	}
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return YES;
}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
}
- (void)viewDidUnload {
    [super viewDidUnload];
    self.lable=nil;
	self.switch1=nil;
	self.popoverController=nil;
	self.toolbar=nil;
}
- (void)dealloc {
	[self.toolbar release];
	[self.popoverController release];
	[self.lable release];
	[self.switch1 release];
    [super dealloc];
}

#pragma mark -
#pragma mark Split view support
//竖屏
- (void)splitViewController: (UISplitViewController*)svc willHideViewController:(UIViewController *)aViewController withBarButtonItem:(UIBarButtonItem*)barButtonItem forPopoverController: (UIPopoverController*)pc {
    barButtonItem.title = @"列表";
    NSMutableArray *items = [[toolbar items] mutableCopy];
    [items insertObject:barButtonItem atIndex:0];
    [toolbar setItems:items animated:YES];
    [items release];
    self.popoverController = pc;
}
//横屏
// Called when the view is shown again in the split view, invalidating the button and popover controller.
- (void)splitViewController: (UISplitViewController*)svc willShowViewController:(UIViewController *)aViewController invalidatingBarButtonItem:(UIBarButtonItem *)barButtonItem {
    NSMutableArray *items = [[toolbar items] mutableCopy];
    [items removeObjectAtIndex:0];
    [toolbar setItems:items animated:YES];
    [items release];
    self.popoverController = nil;
}
@end
